
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title>
        医生信息
    </title>

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>医生管理</cite></a>
              <a><cite>医生信息</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center" action="" style="width:80%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">

                <div class="layui-input-inline">
                    <input type="text" id="dc_ID"  placeholder="请输入医生ID" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width:80px">
                    <button type="button" class="layui-btn" id="btnfindByDC_ID" ><i class="layui-icon">&#xe615;</i></button>
                </div>
                <div class="layui-input-inline">
                    <label></label>
                </div>
                <div class="layui-input-inline">
                    <input type="text" id="dc_NAME" placeholder="请输入医生姓名" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn" type="button" id="btnfindByDC_NAME" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                </div>
            </div>
        </div>
    </form>
    <xblock>
        <button class="layui-btn" onclick="admin_add('添加','communityadd.html','1000','600')"><i class="layui-icon">&#xe608;</i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：<span class="layui-badge"><label id="dc_n"></label></span> 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>#</th>
            <th>
                医生ID
            </th>

            <th>
                用户名
            </th>
            <th>
                密码
            </th>
            <th>
                年龄
            </th>
            <th>
                科室
            </th>
            <th>
                候诊数
            </th>
            <th>
                真实姓名
            </th>
            <th>
               操作
            </th>
        </tr>
        </thead>
        <tbody id="dcInfo">
        <tr>
            <td>
                2
            </td>
            <td >
                XY20191210001
            </td>
            <td >
                金华万府
            </td>
            <td >
                XXX市
            </td>
            <td >
                12000
            </td>
            <td >
                12
            </td>
            <td >
                200
            </td>
            <td class="td-manage">
                <a title="编辑" href="javascript:;" onclick="" class="ml-5" style="text-decoration:none">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" href="javascript:;" onclick="" style="text-decoration:none">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>

    <div id="page">
    <ul class="pagination" id="fanye">
        <li class="disabled"><span>&laquo;</span></li>
        <li class="active"><span>1</span></li><li>
        <a href="/xiyuan/Community/lst?page=2">2</a></li>
        <li><a href="/xiyuan/Community/lst?page=2">&raquo;</a></li>

    </ul></div>
</div>

<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>

   layui.use(['laydate','element','laypage','layer'], function() {
       $ = layui.jquery;//jquery
       laydate = layui.laydate;//日期插件
       lement = layui.element();//面包导航
       laypage = layui.laypage;//分页
       layer = layui.layer;//弹出层
       okLoading.close($);
       layer.ready(function () { //为了layer.ext.js加载完毕再执行
           layer.photos({
               photos: '#x-img'
               //,shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
           });
       });
   })
    $(function () {
        doctorInfo()
        $("#btnfindByDC_ID").click(function (){
            var id = $("#dc_ID").val()
            // alert(id)
            $.ajax({
                url: "/doctor/findById?dc_ID="+id,
                async:true,
                dataType: "json",
                contentType:"application/json",
                // data:{dc_ID:id},
                success:function (res){
                    if(res.state === 200) {
                        var e = res.data
                        $("#dcInfo").empty()
                        $("#dcInfo").append("<tr>")
                            .append("<td>"+ 1 +"</td>")
                            .append("<td>" + e.dc_ID + "</td>")
                            .append("<td>" + e.userName + "</td>")
                            .append("<td>" + e.password + "</td>")
                            .append("<td>" + e.age + "</td>")
                            .append("<td>" + e.clinic + "</td>")
                            .append("<td>" + e.access + "</td>")
                            .append("<td>" + e.realName + "</td>")
                            .append("<td>" +
                        "<button type='button' class='btn btn-primary col-md-3' onclick='community_edit("+e.dc_ID+")'>修改</button>"+
                        "<button type='button' class='btn btn-success col-md-3' onclick='dc_del("+e.dc_ID+")' value='删除'>删除</button>" +
                        "</td></tr>")
                    }
                    $("#dc_n").text(1);
                }
            })
        })
        $("#btnfindByDC_NAME").click(function (){
            var name = $("#dc_NAME").val()
            // alert(name)
            $.ajax({
                url:"/doctor/findByName?username="+name,
                dataType:"json",
                contentType: "application/json",
                success: function (res){
                    if(res.state === 200){
                        var e = res.data
                        $("#dcInfo").empty()
                        $("#dcInfo").append("<tr>")
                            .append("<td>"+1 +"</td>")
                            .append("<td>" + e.dc_ID + "</td>")
                            .append("<td>" + e.userName + "</td>")
                            .append("<td>" + e.password + "</td>")
                            .append("<td>" + e.age + "</td>")
                            .append("<td>" + e.clinic + "</td>")
                            .append("<td>" + e.access + "</td>")
                            .append("<td>" + e.realName + "</td>")
                            .append("<td>" +
                        "<button type='button' class='btn btn-primary col-md-3' onclick='community_edit("+e.dc_ID+")'>修改</button>"+
                        "<button type='button' class='btn btn-success col-md-3' onclick='dc_del("+e.dc_ID+")' value='删除'>删除</button>" +
                        "</td></tr>")
                        $("#dc_n").text(1);
                    }
                }
            })
        })
        fanye()

    })

        /*添加*/
   function admin_add(title,url,w,h){
       x_admin_show(title,url,w,h);
   }
       //编辑
   function community_edit (id) {
       url = "communitymod.html?dc_ID="+id;
       x_admin_show('修改',url,1000,600);
   }

       /*删除*/
   function dc_del(dc_id){
       $.ajax({
           url:"/doctor/delete?dc_ID="+dc_id,
           dataType:"json",
           success: function (res){
               if(res.state === 200){
                   alert("删除成功")
                   location.reload()
               }
           }
       })
   }
function fanye(){
    var yema = $("#fanye").empty()
    var page = $("#dc_n").val();
    yema.append("<li id='backpage'><span>&laquo;</span></li>")
    for (let i = 1; i <= (page/10)+1; i++) {
        yema.append("<li><span id='page'>"+i+"</span></li><li>")
    }
    yema.append("<li id='nextpage'><span>&raquo;</span></li>")

}

       function doctorInfo() {
           $.ajax({
               url: "/doctor/findAll",
               dataType: "json",
               async:true,
               success(res) {
                   if (res.state === 200) {
                       var n = 0;
                       $("#dcInfo").empty()
                       $.each(res.data, function (i, e) {
                           n++;
                           $("#dcInfo").append("<tr>")
                               .append("<td>" + (i+1) +"</td>")
                               .append("<td>" + e.dc_ID + "</td>")
                               .append("<td>" + e.userName + "</td>")
                               .append("<td>" + e.password + "</td>")
                               .append("<td>" + e.age + "</td>")
                               .append("<td>" + e.clinic + "</td>")
                               .append("<td>" + e.access + "</td>")
                               .append("<td>" + e.realName + "</td>")
                               .append("<td>" +
                                   "<button type='button' class='btn btn-primary col-md-3' onclick='community_edit("+e.dc_ID+")'>修改</button>"+
                                   "<button type='button' class='btn btn-success col-md-3' onclick='dc_del("+e.dc_ID+")' value='删除'>删除</button>" +
                                   "</td></tr>")

//<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">
                       })
                       $("#dc_n").text(n);
                   }
               }
           })
       }

</script>

</body>
</html>